package com.bindapp.model;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.bindapp.R;
import com.bindapp.activity.SetPassActivity;
import com.bindapp.databinding.ActivitySzBinding;
import com.bindapp.util.AppManager;

import java.util.HashMap;

/**
 * Created by apple on 2018/7/8.
 */

public class SettingModel extends BaseModel {
    private ActivitySzBinding binding;

    public SettingModel(Context context){
        super(context);
        binding= DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.activity_sz,null,false);
        binding.setClick(new ViewClick());
    }

    @Override
    public ActivitySzBinding getBinding() {
        return binding;
    }


    public class ViewClick{
        public void onClick(View view){
            switch(view.getId()){
                case R.id.item1:
                    turnToVc(SetPassActivity.class,new HashMap<String,Object>());
                    break;
                case R.id.exitapp:
                    /*PreferencesUtil.getInstance(context).setPassword("");
                    PreferencesUtil.getInstance(context).setPhonenum("");
                    turnToVc(LoginActivity.class,new HashMap<String,Object>());*/
                    new MaterialDialog.Builder(context).title("提示")
                            .content("确定要退出吗？")
                            .negativeText("取消")
                            .onNegative(new MaterialDialog.SingleButtonCallback() {
                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    dialog.dismiss();
                                }
                            })
                            .positiveText("确定")
                            .onPositive(new MaterialDialog.SingleButtonCallback() {
                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    dialog.dismiss();
                                    AppManager.AppExit(context);
                                }
                            }).show();

                    break;
            }
        }
    }
}
